<!-- 新增/编辑API模态框 -->
<div class="modal fade" id="addEditModal" tabindex="-1" aria-labelledby="addEditModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-xl">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="addEditModalLabel">新增API</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="add-edit-form">
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label for="api-name" class="form-label">API名称</label>
                            <input type="text" class="form-control" id="api-name" required>
                        </div>
                        <div class="col-md-3">
                            <label for="api-method" class="form-label">请求方法</label>
                            <select class="form-select" id="api-method" required>
                                <option value="GET">GET</option>
                                <option value="POST">POST</option>
                                <option value="PUT">PUT</option>
                                <option value="DELETE">DELETE</option>
                                <option value="PATCH">PATCH</option>
                                <option value="HEAD">HEAD</option>
                                <option value="OPTIONS">OPTIONS</option>
                            </select>
                        </div>
                        <div class="col-md-3">
                            <label for="api-tags" class="form-label">标签</label>
                            <input type="text" class="form-control" id="api-tags" placeholder="用逗号分隔">
                        </div>
                    </div>
                    
                    <div class="mb-3">
                        <label for="api-path" class="form-label">请求路径</label>
                        <input type="text" class="form-control" id="api-path" placeholder="/api/v1/example" required>
                    <input type="hidden" id="api-id">
                    </div>
                    
                    <div class="mb-3">
                        <label for="api-description" class="form-label">描述</label>
                        <textarea class="form-control" id="api-description" rows="2"></textarea>
                    </div>
                    
                    <ul class="nav nav-tabs" id="apiTabs" role="tablist">
                        <li class="nav-item" role="presentation">
                            <button class="nav-link active" id="headers-tab" data-bs-toggle="tab" data-bs-target="#headers-tab-pane" type="button" role="tab" aria-controls="headers-tab-pane" aria-selected="true">请求头</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button class="nav-link" id="params-tab" data-bs-toggle="tab" data-bs-target="#params-tab-pane" type="button" role="tab" aria-controls="params-tab-pane" aria-selected="false">请求参数</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button class="nav-link" id="body-tab" data-bs-toggle="tab" data-bs-target="#body-tab-pane" type="button" role="tab" aria-controls="body-tab-pane" aria-selected="false">请求体</button>
                        </li>
                        <li class="nav-item" role="presentation">
                            <button class="nav-link" id="response-tab" data-bs-toggle="tab" data-bs-target="#response-tab-pane" type="button" role="tab" aria-controls="response-tab-pane" aria-selected="false">响应</button>
                        </li>
                    </ul>
                    
                    <div class="tab-content p-3 border border-top-0 rounded-bottom" id="apiTabsContent">
                        <div class="tab-pane fade show active" id="headers-tab-pane" role="tabpanel" aria-labelledby="headers-tab" tabindex="0">
                            <div class="mb-3">
                                <label for="api-headers" class="form-label">请求头 (JSON格式)</label>
                                <textarea class="form-control" id="api-headers" rows="8">{}</textarea>
                            </div>
                        </div>
                        <div class="tab-pane fade" id="params-tab-pane" role="tabpanel" aria-labelledby="params-tab" tabindex="0">
                            <div class="mb-3">
                                <label for="api-params" class="form-label">请求参数 (JSON格式)</label>
                                <textarea class="form-control" id="api-params" rows="8">{}</textarea>
                            </div>
                        </div>
                        <div class="tab-pane fade" id="body-tab-pane" role="tabpanel" aria-labelledby="body-tab" tabindex="0">
                            <div class="mb-3">
                                <label for="api-body" class="form-label">请求体 (JSON格式)</label>
                                <textarea class="form-control" id="api-body" rows="8">{}</textarea>
                            </div>
                        </div>
                        <div class="tab-pane fade" id="response-tab-pane" role="tabpanel" aria-labelledby="response-tab" tabindex="0">
                            <div class="mb-3">
                                <label for="api-response" class="form-label">响应 (JSON格式)</label>
                                <textarea class="form-control" id="api-response" rows="8">{}</textarea>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <button type="submit" form="add-edit-form" class="btn btn-primary">保存</button>
            </div>
            
            <!-- 所有脚本功能已移至api_functions_part1.js -->
        </div>
    </div>
</div>